<template>
  <div id="superUser_proposal">
    <el-main>
      <el-table :data="proposal">
        <el-table-column prop="name" label="昵称" width="150">
        </el-table-column>
        <el-table-column prop="proposal" label="建议" width="300">
        </el-table-column>
        <el-table-column prop="proposalTime" label="发起时间" width="200">
        </el-table-column>
        <el-table-column prop="email" label="联系方式(邮箱)" width="200">
        </el-table-column>
        <el-table-column prop="proposal_state" label="状态" width="100">
          <template slot-scope="scope">
            <scpen v-if="+scope.row.proposalState===0">未读</scpen>
            <scpen v-else-if="+scope.row.proposalState===1">已读</scpen>
          </template>
        </el-table-column>
        <el-table-column prop="proposal_state" label="操作" width="300">
          <template slot-scope="scope">
            <el-button @click="readProposal(scope.row.id)" type="success" plain v-if="+scope.row.proposalState===0">已读</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-main>
  </div>
</template>

<script>
export default {
  name: "superUser_proposal",
  props: {
    proposal: {
      type: Array,
      default: () => []
    },
  },
  methods:{
    readProposal(id){
      this.$http.get("http://localhost:8088/superUser/readProposal",{
        params:{
          id:id,
        }
      }).then(resp=>{
        console.log(resp.data)
        this.$http.get("http://localhost:8088/superUser/findProposalAll", {
        }).then(resp => {
          this.proposal = resp.data
          this.$router.push({
            name: 'superUser_proposal',
            query: {
              proposal: this.proposal,
            }
          }).catch(err => {
            console.log(err)
          })
        })
      })
    }
  }

}
</script>

<style scoped>

</style>